/**
 * 是否包含元素
 * @param val 值
 * @param key 属性名，数组对象才生效 (可选，值类型数组不填)
 * @returns {boolean}
 */
Array.prototype.contains = function (val, key) {
    var isContains = false;
    for (var i = 0; i < this.length; i++) {
        if (key && key != "") {
            if (this[i][key] == val) {
                isContains = true;
                break;
            }
        } else {
            if (this[i] == val) {
                isContains = true;
                break;
            }
        }
    }
    return isContains;
};

/**
 * 查找集合中的对象
 * @param val 对象值
 * @param key 属性名，数组对象才生效 (可选，值类型数组不填)
 * @returns {*}
 */
Array.prototype.findObj = function (val, key) {
    var con=null;
    for (var i = 0; i < this.length; i++) {
        if (key && key != "") {
            if (this[i][key] == val) {
                con = this[i];
                break;
            }
        } else {
            if (this[i] == val) {
                con = this[i];
                break;
            }
        }
    }
    return con;
};

/**
 * 查找集合中的对象集合
 * @param val 对象值
 * @param key 属性名，数组对象才生效 (可选，值类型数组不填)
 * @returns {Array}
 */
Array.prototype.filterObj = function (val, key) {
    var con=[];
    for (var i = 0; i < this.length; i++) {
        if (key && key != "") {
            if (this[i][key] == val) {
                con.push(this[i]);
            }
        } else {
            if (this[i] == val) {
                con.push(this[i]);
            }
        }
    }
    return con;
};

/**
 * 删除元素（有多个则删除多个）
 * @param val 值
 * @param key 数组对象才生效,属性名
 * @returns {number} 返回成功删除个数
 */
Array.prototype.remove = function (val, key) {
    var num = 0;
    for (var i = this.length-1; i >=0; i--) {
        if (key && key != "") {
            if (this[i][key] == val) {
                this.splice(i, 1);
                num++;
            }
        } else {
            if (this[i] == val) {
                this.splice(i, 1);
                num++;
            }
        }
    }
    return num;
};

/**
 * 降序
 * @param proName 属性名 可选参数
 * @returns {Array}
 */
Array.prototype.descending = function(proName) {
    var oValue;
    if(proName){
        for (var i = 0; i < this.length; i++) {
            for (var j = 0; j <= i; j++) {
                if (this[i][proName] > this[j][proName]) {
                    oValue = this[i];
                    this[i] = this[j];
                    this[j] = oValue;
                }
            }
        }
    }else{
        for (var i = 0; i < this.length; i++) {
            for (var j = 0; j <= i; j++) {
                if (this[i] > this[j]) {
                    oValue = this[i];
                    this[i] = this[j];
                    this[j] = oValue;
                }
            }
        }
    }
    return this;
};

/**
 * 升序
 * @param proName 属性名 可选参数
 * @returns {Array}
 */
Array.prototype.ascending = function(proName) {
    var oValue;
    if(proName){
        for (var i = 0; i < this.length; i++) {
            for (var j = 0; j <= i; j++) {
                if (this[i][proName] < this[j][proName]) {
                    oValue = this[i];
                    this[i] = this[j];
                    this[j] = oValue;
                }
            }
        }
    }else{
        for (var i = 0; i < this.length; i++) {
            for (var j = 0; j <= i; j++) {
                if (this[i] < this[j]) {
                    oValue = this[i];
                    this[i] = this[j];
                    this[j] = oValue;
                }
            }
        }
    }
    return this;
};


/**
 * 去空格
 * @returns {string}
 */
String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
};

/**
 * 全局替换
 * @param s1
 * @param s2
 * @returns {string}
 */
String.prototype.replaceAll  = function(s1,s2){
    return this.replace(new RegExp(s1,"gm"),s2);
};

/**
 *右对齐此实例中的字符，在左边用指定的 Unicode 字符填充以达到指定的总长度。
 * @param totalWidth
 * @param paddingChar
 * @returns {String}
 */
String.prototype.padLeft = function(totalWidth, paddingChar){
    var result=this;
    if (this.length < totalWidth){
        var paddingString = new String();
        for (var i = 1; i <= (totalWidth - this.length); i++){
            paddingString += paddingChar;
        }
        result=paddingString + this;
    }
    return result;
};

/**
 * 左对齐此字符串中的字符，在右边用空格填充以达到指定的总长度。
 * @param totalWidth
 * @param paddingChar
 * @returns {String}
 * @constructor
 */
String.prototype.PadRight = function(totalWidth, paddingChar){
    var result=this;
    if (this.length < totalWidth){
        var paddingString = new String();
        for (var i = 1; i <= (totalWidth - this.length); i++){
            paddingString += paddingChar;
        }
        result=this+paddingString;
    }
    return result;
};

/**
 * 转换为时间格式
 * @returns {*}
 */
String.prototype.toDate=function(){
    var date;
    var value=this.replace(new RegExp("/","gm"),"-");
    var mr=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2}):(\d{1,3})$/.exec(value);
    if(!mr){
        mr = /^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/.exec(value);
    }
    if(!mr){
        mr=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})$/.exec(this);
    }
    if(!mr){
        mr=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2})$/.exec(this);
    }
    if(!mr){
        mr=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(this);
    }
    if (mr) {
        var year=parseInt(mr[1]);
        var month=parseInt(mr[2])-1;
        var day=parseInt(mr[3]);
        var hour=mr.length>4?parseInt(mr[4]):0;
        var minute=mr.length>5?parseInt(mr[5]):0;
        var second=mr.length>6?parseInt(mr[6]):0;
        var millisecond=mr.length>7?parseInt(mr[7]):0;
        date = new Date(year,month,day,hour,minute,second,millisecond);
    }
    return date;
};

/**
 * 将 Date 转化为指定格式的String
 * @param fmt 年（Y）、月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q) 可以用 1-2 个占位符,
 * 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
 * @returns {*}
 */
Date.prototype.format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时
        "H+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    var week = {
        "0": "\u65e5",
        "1": "\u4e00",
        "2": "\u4e8c",
        "3": "\u4e09",
        "4": "\u56db",
        "5": "\u4e94",
        "6": "\u516d"
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    if (/(E+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") : "") + week[this.getDay() + ""]);
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        }
    }
    return fmt;
};


/**
 * 加法函数，用来得到精确的加法结果
 * @param arg1 被加数
 * @returns {number}
 */
Number.prototype.accAdd = function (arg1) {
    return AFC.math.accAdd(this, arg1);
};

/**
 * 减法函数，用来得到精确的减法结果
 * @param arg1 被减数
 * @returns {string}
 */
Number.prototype.accSub = function (arg1) {
    return AFC.math.accSub(this, arg1);
};

/**
 * 乘法函数，用来得到精确的乘法结果
 * @param arg1 被乘数
 * @returns {number}
 */
Number.prototype.accMul = function (arg1) {
    return AFC.math.accMul(this, arg1);
};

/**
 * 除法函数，用来得到精确的除法结果
 * @param arg1 被除数
 * @returns {number}
 */
Number.prototype.accDiv = function (arg1) {
    return AFC.math.accDiv(this, arg1);
};


var AFC={};

/**
 * 获取GUID
 * @returns {string}
 */
AFC.newGuid = function () {
    var guid = "";
    for (var i = 1; i <= 32; i++) {
        var n = Math.floor(Math.random() * 16.0).toString(16);
        guid += n;
        if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
            guid += "";
    }
    return guid;
};

/**
 * 获取URL参数值
 * @param name 参数名
 * @returns {null}
 */
AFC.getQueryString = function (name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
};

/**
 * 获取URL地址
 * @returns {string}
 */
AFC.getURLPathname=function(){
    var currentUrl=window.location.pathname.trim();
    return currentUrl;
};

/**
 * 获取URL地址（包含参数）
 * @returns {string}
 */
AFC.getURLPath=function(){
    var currentUrl=window.location.pathname.trim();
    if(window.location.search){
        currentUrl+=window.location.search.trim();
    }
    return currentUrl;
};

/**
 * 获取浏览器默认语言
 * @returns {string}
 */
AFC.getBrowserLanguage=function(){
    //判断除IE外其他浏览器使用语言
    var currentLang = navigator.language;
    if(!currentLang){//判断IE浏览器使用语言
        currentLang = navigator.browserLanguage;
    }
    return currentLang;
};

/**
 * 获取cookie
 * @param name
 * @returns {string}
 */
AFC.getCookie=function(name){
    var result="";
    if (document.cookie && document.cookie.length>0){
        var c_start=document.cookie.indexOf(name + "=");
        if (c_start!=-1){
            c_start=c_start + name.length+1;
            var c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) {
                c_end=document.cookie.length;
            }
            result= unescape(document.cookie.substring(c_start,c_end));
        }
    }
    return result;
};

/**
 * 生成随机数
 * @param startNum
 * @param endNum
 * @returns {Number}
 */
AFC.random=function (startNum,endNum) {
    return parseInt(Math.random()*endNum+startNum, 10);
};

/**
 * 添加事件
 * @param oTarget 需要添加事件的DOM元素
 * @param sEventType 事件名称
 * @param fnHandler 调用事件的函数
 */
AFC.addEventHandler = function (oTarget, sEventType, fnHandler) {
    if (oTarget && sEventType) {
        if (oTarget.addEventListener) {
            oTarget.addEventListener(sEventType, fnHandler, false);
        } else if (oTarget.attachEvent) {
            oTarget.attachEvent("on" + sEventType, fnHandler);
        } else {
            oTarget["on" + sEventType] = fnHandler;
        }
    }
};

/**
 * 删除注销事件
 * @param target 需要删除事件的DOM元素
 * @param eventName 事件名称
 * @param func 事件函数
 */
AFC.removeEventHandler = function (target, eventName, func) {
    if (target && eventName) {
        if (target.detachEvent) {
            target.detachEvent('on' + eventName, func);
        } else if (target.removeEventListener) {
            target.removeEventListener(eventName, func, false);
        } else {
            target['on' + eventName] = null;
        };
    }
};

/**
 * 转换为时间
 * @param val 格式为：20151011121211999等格式
 * @returns {*}
 */
AFC.toDate=function(val){
    var date=null;
    if(val!=null && val!=undefined){
        var dateVal= val.toString().trim();
        var year,month,day,hour,minute,second, millisecond;
        if(dateVal.length>=4){
            year=parseInt(dateVal.substring(0,4));
        }
        if(dateVal.length>=6){
            month=parseInt(dateVal.substring(4,6))-1;
        }
        if(dateVal.length>=8){
            day=parseInt(dateVal.substring(6,8));
        }
        if(dateVal.length>=10){
            hour=parseInt(dateVal.substring(8,10));
        }
        if(dateVal.length>=12){
            minute=parseInt(dateVal.substring(10,12))-1;
        }
        if(dateVal.length>=14){
            second=parseInt(dateVal.substring(12,14));
        }
        if(dateVal.length>=17){
            millisecond=parseInt(dateVal.substring(14,17));
        }
        if(year!=null && year!=undefined && month!=null && month!=undefined){
            date = new Date(year,month,1);
            if(day){
                date.setDate(day);
            }
            if(hour){
                date.setHours(hour);
            }
            if(minute){
                date.setMinutes(minute);
            }
            if(second){
                date.setSeconds(second);
            }
            if(millisecond){
                date.setMilliseconds(millisecond);
            }
        }

    }
    return date;
};

/**
 * 长整形时间转字符串
 * @param val 格式为：20151011121211999等格式
 * @param frm 年（Y）、月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q) 可以用 1-2 个占位符,
 * @returns {string}
 */
AFC.longDateToStr=function(val,frm){
    var result="";
    var date= AFC.toDate(val);
    if(date){
        result=date.format(frm);
    }
    return result;
};

/**
 * FORM get形式页面跳转
 * @param url
 */
AFC.redirect=function (url) {
    var num=url.indexOf("?");
    var urlPath=url.substr(0,num);
    var urlParam=url.substr(num+1);
    //var
    var tempForm='<form target="_blank" name="myform" action="'+urlPath+'" method="get">';
    var arr=str.split("&");
    for(var i=0;i < arr.length;i++){
        var paramNum=arr[i].indexOf("=");
        if(paramNum>0){
            var name=arr[i].substring(0,paramNum);
            var value=arr[i].substr(paramNum+1);
            tempForm+='<input type="text" name="'+name+'" value="'+value+'" />';
        }
    }
    tempForm+='</form>';
    $("body").append(tempForm);
    tempForm.submit();
    tempForm.remove();
};

/**
 * 设置默认值
 * @param obj
 * @param defVal
 * @returns {*}
 */
AFC.setDefaultVal=function (obj,defVal) {
    var result=obj;
    if(obj==null || obj==undefined){
        result=defVal;
    }
    return result;
};

/**
 * 数学计算
 * @type {{}}
 */
AFC.math={};

/**
 * 加法函数，用来得到精确的加法结果
 * @param arg1 加数
 * @param arg2 被加数
 * @returns {number}
 */
AFC.math.accAdd = function (arg1, arg2) {
    var r1, r2, m, c;
    try {
        var argsub1 = arg1.toString().split(".");
        if (argsub1.length > 1) {
            r1 = argsub1[1].length;
        } else {
            r1 = 0;
        }
    }
    catch (e) {
        r1 = 0;
    }
    try {
        var argsub2 = arg2.toString().split(".");
        if (argsub2.length > 1) {
            r2 = argsub2[1].length;
        } else {
            r2 = 0;
        }
    }
    catch (e) {
        r2 = 0;
    }
    c = Math.abs(r1 - r2);
    m = Math.pow(10, Math.max(r1, r2));
    if (c > 0) {
        var cm = Math.pow(10, c);
        if (r1 > r2) {
            arg1 = Number(arg1.toString().replace(".", ""));
            arg2 = Number(arg2.toString().replace(".", "")) * cm;
        } else {
            arg1 = Number(arg1.toString().replace(".", "")) * cm;
            arg2 = Number(arg2.toString().replace(".", ""));
        }
    } else {
        arg1 = Number(arg1.toString().replace(".", ""));
        arg2 = Number(arg2.toString().replace(".", ""));
    }
    return (arg1 + arg2) / m;
};

/**
 * 减法函数，用来得到精确的减法结果
 * @param arg1 减数
 * @param arg2 被减数
 * @returns {string}
 */
AFC.math.accSub = function accSub(arg1, arg2) {
    var r1, r2, m, n;
    try {
        var argsub1 = arg1.toString().split(".");
        if (argsub1.length > 1) {
            r1 = argsub1[1].length;
        } else {
            r1 = 0;
        }
    }
    catch (e) {
        r1 = 0;
    }
    try {
        var argsub2 = arg2.toString().split(".");
        if (argsub2.length > 1) {
            r2 = argsub2[1].length;
        } else {
            r2 = 0;
        }
    }
    catch (e) {
        r2 = 0;
    }
    m = Math.pow(10, Math.max(r1, r2)); //last modify by deeka //动态控制精度长度
    n = (r1 >= r2) ? r1 : r2;
    return ((arg1 * m - arg2 * m) / m).toFixed(n);
};

/**
 * 乘法函数，用来得到精确的乘法结果
 * @param arg1 乘数
 * @param arg2 被乘数
 * @returns {number}
 */
AFC.math.accMul = function (arg1, arg2) {
    var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
    try {
        var argsub1 = s1.split(".");
        if (argsub1.length > 1) {
            m += argsub1[1].length;
        }
    }
    catch (e) {
    }
    try {
        var argsub2 = s2.split(".");
        if (argsub2.length > 1) {
            m += argsub2[1].length;
        }
    }
    catch (e) {
    }
    return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
};

/**
 * 除法函数，用来得到精确的除法结果
 * @param arg1 除数
 * @param arg2 被除数
 * @returns {number}
 */
AFC.math.accDiv = function (arg1, arg2) {
    var t1 = 0, t2 = 0, r1, r2;
    try {
        var argsub1 = arg1.toString().split(".");
        if (argsub1.length > 1) {
            t1 = argsub1[1].length;
        } else {
            t1 = 0;
        }
    }
    catch (e) {
    }
    try {
        var argsub2 = arg2.toString().split(".");
        if (argsub2.length > 1) {
            t2 = argsub2[1].length;
        } else {
            t2 = 0;
        }
    }
    catch (e) {
    }
    with (Math) {
        r1 = Number(arg1.toString().replace(".", ""));
        r2 = Number(arg2.toString().replace(".", ""));
        return (r1 / r2) * pow(10, t2 - t1);
    }
};

/**
 * 验证
 * @type {{}}
 */
AFC.validate = {};

AFC.validate.isBlank=function (str) {
    var val=str||'';
    val=val.trim();
    if(val!=""){
        return false;
    }else{
        return true;
    }
};

/**
 * 是否空对象
 * @param val
 * @returns {boolean}
 */
AFC.validate.isNull=function (val) {
    if(val!=null && val!=undefined){
        return false;
    }else{
        return true;
    }
};

/**
 * 是否字符串
 * @param _str
 * @returns {boolean|*}
 */
AFC.validate.isString = function (_str) {
    return typeof _str == "string" || (_str && (typeof _str.substr == 'function'));
};

/**
 * 是否正整数包括0
 * @param obj
 * @returns {boolean}
 */
AFC.validate.digits = function (obj) {
    var re = /^[0-9]*[1-9][0-9]*$/ ;
    var result=re.test(obj);
    if(obj=="0"){
        result=true;
    }
    return result;
};

/**
 * 验证大于0数字(包含小数)
 * @param obj
 * @returns {boolean}
 */
AFC.validate.isFloatGtZero = function (obj) {
    var parnt = /^[1-9]\d*(\.\d+)?$/;
    if(!parnt.exec(obj)){
        return false;
    }else{
        return true;
    }
};

/**
 * 验证是否时间格式
 * @param obj
 * @returns {boolean}
 */
AFC.validate.dateISO = function (obj) {
    var r = /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/;
    return r.test(obj);
};

/**
 * 是否有效身份证号码
 * @param num
 * @returns {boolean}
 */
AFC.validate.isIdCardNo = function (num) {
    var value = num.toUpperCase();
    var result=false;
    if ((/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(value))) {
        var aCity = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江 ", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外" };
        if (aCity[parseInt(value.substr(0, 2))] != null) {
            var len, re; len = value.length;
            if (len == 15) {
                re = new RegExp(/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/);
                var arrSplit = value.match(re);  //检查生日日期是否正确
                var dtmBirth = new Date('19' + arrSplit[2] + '/' + arrSplit[3] + '/' + arrSplit[4]);
                var bGoodDay;
                bGoodDay = (dtmBirth.getYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4]));
                if (bGoodDay) {
                    var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
                    var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
                    var nTemp = 0, i;
                    value = value.substr(0, 6) + '19' + value.substr(6, value.length - 6);
                    for (i = 0; i < 17; i++) {
                        nTemp += value.substr(i, 1) * arrInt[i];
                    }
                    value += arrCh[nTemp % 11];
                    result= true;
                }
            }else if (len == 18) {
                re = new RegExp(/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/);
                var arrSplit = num.match(re);  //检查生日日期是否正确
                var dtmBirth = new Date(arrSplit[2] + "/" + arrSplit[3] + "/" + arrSplit[4]);
                var bGoodDay;
                bGoodDay = (dtmBirth.getFullYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4]));
                if (bGoodDay) {
                    var valnum;
                    var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
                    var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
                    var nTemp = 0, i;
                    for (i = 0; i < 17; i++) {
                        nTemp += num.substr(i, 1) * arrInt[i];
                    }
                    valnum = arrCh[nTemp % 11];
                    if (valnum == value.substr(17, 1)) {
                        result= true;
                    }
                }
            }
        }
    }
    return result;
};

/**
 * 是否手机号码
 * @param str
 * @returns {Array|{index: number, input: string}}
 */
AFC.validate.isMobile = function (str) {
    var patrn = /^((13[0-9])|(14[0-9])|(17[0-9])|(15[0-35-9])|(18[0,2,3,5-9]))\d{8}$/;
    return patrn.exec(str);
};

/**
 * 验证字符串是否不包含特殊字符
 * @param str
 * @returns {Array|{index: number, input: string}}
 */
AFC.validate.isUnSymbols = function (str) {
    var p = /^[\u4e00-\u9fa5\w \.,()，ê?。¡ê（ê¡§）ê?]+$/;
    return p.exec(str);
};


AFC.JSON={};
/**
 * JSON转换为字符串
 * @param val
 */
AFC.JSON.stringify=function(val){
    return JSON.stringify(val);
};

/**
 * 字符串转换为JSON
 * @param val
 */
AFC.JSON.parseJSON=function(val){
    return eval('(' + val + ')');
};

AFC.excute=function(){

};

AFC.ajax={};

AFC.ajax=function(settings){
    if (typeof jQuery === "undefined") {
        throw new Error("requires jQuery");
    }
    var ajaxSettings = $.extend({}, jQuery.ajaxSettings, settings);
    ajaxSettings.error=function(XMLHttpRequest, textStatus, errorThrown){
        var errorMsg="";
        if(textStatus){
            errorMsg+=textStatus;
        }
        if(XMLHttpRequest.status!=undefined){
            errorMsg+=" "+"错误码："+XMLHttpRequest.status;
        }
        if(errorThrown){
            errorMsg+=" "+errorThrown;
        }
        var resultData={
            status:false,
            message:errorMsg
        };
        if(ajaxSettings.success){
            ajaxSettings.success(resultData);
        }
    };
    $.ajax(ajaxSettings);
};

AFC.ajax.postJSON=function(url,data,callback){
    var ajaxSettings={
        url:url,
        type:"POST",
        dataType:"json",
        data:data,
        success:callback
    };
    AFC.ajax(ajaxSettings);
};

AFC.ajax.getJSON=function(url,data,callback){
    var ajaxSettings={
        url:url,
        type:"GET",
        dataType:"json",
        data:data,
        success:callback
    };
    AFC.ajax(ajaxSettings);
};

/**
 * 图片自适应
 * @param imgObj 图片对象
 * @param parentObj 父级容器
 */
AFC.imgAdapt=function (imgObj,parentObj) {
    var imgWidth= $(imgObj).width();
    var imgHeight=$(imgObj).height();
    var panelWidth,panelHeight;
    if(parentObj && $(parentObj).length>0){
        panelWidth=$(parentObj).width();
        panelHeight=$(parentObj).height();
    }else{
        panelWidth=$(imgObj).parent().width();
        panelHeight=$(imgObj).parent().height();
    }
    if(imgWidth/panelWidth>imgHeight/panelHeight){
        $(imgObj).css("width",panelWidth);
    }else{
        $(imgObj).css("height",panelHeight);
    }
    $(imgObj).show();
};

// if(console && console.log){
//     console.log("%c \u5b89\u5168\u8b66\u544a\uff01","font-size:50px;color:red;-webkit-text-fill-color:red;-webkit-text-stroke: 1px black;");
//     console.log("%c \u6b64\u6d4f\u89c8\u5668\u529f\u80fd\u4e13\u4f9b\u5f00\u53d1\u8005\u4f7f\u7528\u3002\u8bf7\u4e0d\u8981\u5728\u6b64\u7c98\u8d34\u6267\u884c\u4efb\u4f55\u5185\u5bb9\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u60a8\u7684\u8d26\u6237\u53d7\u5230\u653b\u51fb\uff0c\u7ed9\u60a8\u5e26\u6765\u635f\u5931 \uff01","font-size: 20px;color:#333");
// }
